#include <iostream>
#include <math.h>

using namespace std;
int T,n,m,l,v,a[1000005][5],chao[1000005],road[1000005],c[1000005];
//a[i][1]=d,a[i][2]=v,a[i][3]=a;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        int nums=0;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>a[i][1]>>a[i][2]>>a[i][3];
        }
        for(int i=0;i<=m;i++){
            chao[i]=0;
        }
        for(int i=1;i<=m;i++){
            cin>>c[i];
            for(int j=1;j<=n;j++){
                if(a[j][1]<=c[i]){
                    long long vv=2*a[j][3]*abs(c[i]-a[j][1])+a[j][2]*a[j][2];
                    if(v*v<vv){
                        chao[j]=1;
                    }
                }
            }
        }
        for(int i=0;i<=l;i++){
            if(chao[i]==1){
                nums++;
            }
        }
        cout<<nums<<" "<<nums<<endl;
    }
    return 0;
}
